package models

import "github.com/astaxie/beego/orm"

type Message struct {
	Id   int64  `orm:"column(id);pk"`
	Name string `orm:"column(name);null"`
	Code string `orm:"column(code);null"`
}

func (t *Message) TableName() string {
	return "t_flow_message"
}

func init() {
	orm.RegisterModel(new(Message))
}

// AddEvent insert a new Event into database and returns
// last inserted Id on success.
func AddMessage(m *Message) (id int64, err error) {
	o := orm.NewOrm()
	o.QueryTable("t_flow_message").Filter("code",m.Code).Delete()
	id, err = o.Insert(m)
	return id,err
}
